package com.qf;

import com.qf.anno.controller.UserController;
import com.qf.anno.service.UserService;
import com.qf.xml.service.ComplexObject;
import com.qf.xml.service.ComplexObject2;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.sql.SQLException;

public class AppMainAnno_xml {

    public static void main(String[] args) throws SQLException {
        ApplicationContext ioc = new ClassPathXmlApplicationContext("application-anno-xml.xml");

        /*Object userService = ioc.getBean("userServiceImpl");

        System.out.println(userService);

        Object userDaoImpl = ioc.getBean("userDaoImpl");
        System.out.println(userDaoImpl);

        //通过类型获取bean对象(如果容器中有多个类型一样的对象，就会报错，此时我们只能通过名字获取)
        UserService userService1 = ioc.getBean(UserService.class);
        System.out.println(userService1);

        //获取ComplexObject类型的对象
        ComplexObject complexObject = ioc.getBean(ComplexObject.class);
        System.out.println(complexObject);
        //获取ComplexObject2类型的对象
        ComplexObject2 complexObject2 = ioc.getBean(ComplexObject2.class);
        System.out.println(complexObject2);

        System.out.println("===============");
        //通过名字获取@Bean注入的对象
        Object getBean = ioc.getBean("getBean");
        System.out.println(getBean);

        System.out.println("----------------");


        Object usfb = ioc.getBean("usfb");
        System.out.println(usfb);*/


        //演示依赖注入
        //获取controller对象
        UserController userController = (UserController) ioc.getBean("userController");
        userController.show();
    }
}
